<!--  -->
<template>
  <el-container>
    <el-header height="120px">
      <div class="button">
        <span class="active">新歌速递</span>
        <span>新碟上架</span>
      </div>
      <span
        @click="itemClick(index, item.count)"
        class="adress"
        :class="{ active: currentIndex === index }"
        v-for="(item, index) in adress"
        :key="index"
        >{{ item.name }}</span
      >
    </el-header>

    <el-main>
      <NewMusicDetail :musicList="musicList"></NewMusicDetail>
    </el-main>
  </el-container>
</template>

<script>
import { getNewMusic,getMusicUrl } from "util/findMusic.js";

import NewMusicDetail from "components/findMusic/newMusic/NewMusicDetail.vue";
export default {
  name: "",
  components: {
    NewMusicDetail,
  },
  data() {
    return {
      adress: [
        {
          name: "全部",
          count: 0,
        },
        {
          name: "华语",
          count: 7,
        },
        {
          name: "欧美",
          count: 96,
        },
        {
          name: "韩国",
          count: 16,
        },
        {
          name: "日本",
          count: 8,
        },
      ],
      //   adress: ["全部", "华语", "欧美", "韩国", "日本"],
      currentIndex: 0,
      type: "0",
      musicList: [],
    };
  },
  created() {
    this.getNewMusic();
  },
  methods: {
    async getNewMusic() {
      let {
        data: { data },
      } = await getNewMusic(this.type);
      this.musicList = data;
      // console.log(data);
    },
    //切换标签
    itemClick(index, type) {
      this.currentIndex = index;
      this.type = type;
      this.getNewMusic(type);
    },


  },
};
</script>

<style scoped>
.el-header {
  margin-top: 10px;
  padding: 0 100px;
  /* background: #000; */
}
.button {
  border-radius: 50px;
  margin: 20px auto;
  width: 200px;
  height: 30px;
  background: #eee;
  line-height: 30px;
}
.button span {
  cursor: pointer;
  font-size: 14px;
  border-radius: 50px;
  text-align: center;
  width: 100px;
  display: inline-block;
}
.button span:hover {
  background: #ddd;
}
.button span.active {
  background: rgba(189, 180, 180, 0.603);
  color: #fff;
}
.el-header .adress {
  cursor: pointer;
  display: inline-block;
  font-size: 15px;
  font-weight: 500;
  margin-right: 30px;
  padding-bottom: 50px;
}
.el-header .adress.active {
  color: red;
  font-weight: 600;
}
.el-main {
  padding: 0 100px;
}
</style>